package com.ibm.moa.outmail.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ibm.moa.outmail.R;

public class TextImageView extends LinearLayout {
	private TextView textView;
	private ImageView imageView;

	public TextImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView();
	}

	public TextImageView(Context context) {
		super(context);
		initView();
	}

	private void initView() {
		inflate(getContext(), R.layout.view_textimage, this);
		if (isInEditMode()) {
			return;
		}
		textView = (TextView) findViewById(R.id.textView);
		imageView = (ImageView) findViewById(R.id.imageView);
	}

	public TextView getTextView() {
		return textView;
	}

	public ImageView getImageView() {
		return imageView;
	}

	public void setText(CharSequence text) {
		textView.setText(text);
		imageView.setVisibility(View.GONE);
		textView.setVisibility(View.VISIBLE);
	}

	public void setImageResource(int resId) {
		imageView.setImageResource(resId);
		imageView.setVisibility(View.VISIBLE);
		textView.setVisibility(View.GONE);
	}

	public void setImageDrawable(Drawable drawable) {
		imageView.setImageDrawable(drawable);
		imageView.setVisibility(View.VISIBLE);
		textView.setVisibility(View.GONE);
	}
}
